package com.it.gw.modules.station.adapter

import android.content.Context
import android.util.Log
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.it.common.utils.StringUtils
import com.it.common.utils.isNotEmpty
import com.it.data.network.rsp.WrongRecVo
import com.it.gw.R
import com.it.gw.databinding.ItemEqStaticBinding


class EqStaticAdapter(
    var context: Context,
    var listener: (WrongRecVo) -> Unit,
    var datas: List<WrongRecVo>
) : RecyclerView.Adapter<EqStaticAdapter.ViewHolder>() {
    companion object {
        const val TAG = "EqStaticAdapter"
    }

    override fun onCreateViewHolder(
        parent: ViewGroup,
        viewType: Int
    ): ViewHolder {
        val binding =
            ItemEqStaticBinding.inflate(LayoutInflater.from(parent.context), parent, false)
        return ViewHolder(binding)
    }


    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        val data = datas[position]
        Log.d(TAG, "onBindViewHolder: $data")
        holder.binding.t1.setText(data.STNM)
        holder.binding.t2.setText("测站编码:${data.STCD}")
        holder.binding.t3.setText("弃用设备名称:${data.CL_TYPE}")
        holder.binding.t4.setText("运维类型:${data.DATA_NAME}")
        holder.binding.t5.setText("上报人:${data.RES_USERNAME}")
        holder.binding.t6.setText("上报人号码:${data.RES_PHONE}")
        holder.binding.t7.setText("处理人:${data.QUE_USERNAME}")
        holder.binding.t8.setText("处理人号码:${data.QUE_PHONE}")
        holder.binding.t9.setText("问题备注:${data.QUE_CONTENT}")

        holder.binding.root.setOnClickListener {
            listener.invoke(data)
        }

    }


    override fun getItemCount() = datas.size

    class ViewHolder(val binding: ItemEqStaticBinding) : RecyclerView.ViewHolder(binding.root)
}